<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>onchange</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .bord{
            border: 1px dashed #ee2602;
            width: 90%;
            margin: 20px auto;
        }
        .title{
            font-size: 20px;
            font-weight: bold;
            margin: 20px;
        }
        .introduce{
            font-size: 16px;
            margin: 0 0 20px 50px;
        }
        .red{
            color: red;
        }
    </style>
    <script>
        window.onload = function () {
            document.getElementById('sel1').onchange = function () {
                alert("切换成功!");
            };
        };
    </script>
</head>
<body>
<div class="bord">
    <div class="title">onchange</div>
    <div class="introduce">
        onchange 事件会在域的内容改变时发生。
    </div>
</div>
<div class="bord">
    <div class="title">演示效果</div>
    选择字母：<select id="sel1">
    <option id="a" value="">a</option>
    <option id="b" value="">b</option>
    <option id="c" value="">c</option>
                </select>
    &nbsp;
</div>
<div class="bord">
    <div class="title">代码</div>
    <div class="introduce">
        <pre>
              &lt;script&gt;
        window.onload = function () {
            document.getElementById('sel1').onchange = function () {
                alert("切换成功!");
            };
        };
              &lt;/script&gt;

            选择字母：&lt;select id="sel1"&gt;
    &lt;option id="a" value=""&gt;a&lt;/option&gt;
    &lt;option id="b" value=""&gt;b&lt;/option&gt;
    &lt;option id="c" value=""&gt;c&lt;/option&gt;
                &lt;/select&gt;
    &nbsp
        </pre>
    </div>
</div>
</body>
</html>